package com.burmagateway.dao.impl;

import java.util.List;

import com.burmagateway.dao.TourPackageDAO;
import com.burmagateway.model.TourPackage;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class TourPackageDAOImpl implements TourPackageDAO {

	@Autowired
	private SessionFactory sessionFactory;

	public void addTourPackage(TourPackage tourPackage) {
		sessionFactory.getCurrentSession().save(tourPackage);
	}

	@SuppressWarnings("unchecked")
	public List<TourPackage> listTourPackages() {		
		return sessionFactory
				.getCurrentSession().createQuery("from TourPackage").list();
	}

	public void removeTourPackage(Integer id) {

		TourPackage tourPackage = (TourPackage) sessionFactory
				.getCurrentSession().load(TourPackage.class, id);
		if (tourPackage != null) {
			sessionFactory.getCurrentSession().delete(tourPackage);
		}

	}

}
